package com.standardoperationapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.standardoperationapp.R;
import com.standardoperationapp.bean.RfidCodeListBean;
import com.standardoperationapp.global.PlanListItem;

import java.util.List;
import java.util.Map;

public class RFIDWriteAdapter extends BaseAdapter {
    private List<RfidCodeListBean.DataDTO> list;
    private LayoutInflater mInflater;

    public RFIDWriteAdapter(Context context, List<RfidCodeListBean.DataDTO> list1) {
        list = list1;
        mInflater = LayoutInflater.from(context);
    }



    public int getCount() {
        return list.size();
    }

    public Object getItem(int position) {
        return list.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public int getItemViewType(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
        RfidCodeListBean.DataDTO item = list.get(position);
        ViewHolder viewHolder = null;

        if(convertView == null){
            convertView = mInflater.inflate(R.layout.item_rfid_info, null);
            viewHolder= new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }
        else{
            viewHolder = (ViewHolder)convertView.getTag();
        }

        viewHolder.tvCode.setText(item.getMaterCodeName());
        viewHolder.tvType.setText(item.getMaterCategoryName());
        viewHolder.tvName.setText(item.getMaterName());
        viewHolder.tvAddress.setText(item.getAddressName());
        viewHolder.tvWrite.setText(item.getMaterRfidStatus().equals("1") ? "写入成功" : "写入");


        return convertView;
    }
    class ViewHolder {
        protected TextView tvCode,tvName,tvType,tvAddress,tvWrite;

        public ViewHolder(View convertView){
            this.tvCode = (TextView) convertView.findViewById(R.id.tvCode);
            this.tvType = (TextView) convertView.findViewById(R.id.tvType);
            this.tvName = (TextView) convertView.findViewById(R.id.tvName);
            this.tvAddress = (TextView) convertView.findViewById(R.id.tvAddress);
            this.tvWrite = (TextView) convertView.findViewById(R.id.tvWrite);
        }
    }
}
